﻿<%@ Page Title="Create New Client" Language="C#" MasterPageFile="~/MasterPage.master"
    AutoEventWireup="true" CodeFile="Create_Client.aspx.cs" Inherits="admin_Create_Client" %>

<asp:Content ID="Head" ContentPlaceHolderID="head" runat="Server">
    <link href="../styles/admin.css" rel="stylesheet" type="text/css" />

    <script src="../javascripts/jquery-1.4.3.min.js" type="text/javascript"></script>

    <script src="../javascripts/jquery-ui-1.8.5.custom.min.js" type="text/javascript"></script>

    <script type="text/javascript">
        $(function() {
            $(".datepicker").datepicker({ dateFormat: 'dd/mm/yy' });
        });  
    </script>

</asp:Content>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" runat="Server">
    <div id="top_menu">
        <div id="help_button">
            help
        </div>
              <div id="logout">
            <asp:LoginStatus ID="LoginStatus1" runat="server" LogoutPageUrl="../Default.aspx"
                OnLoggingOut="LoginStatus1_LoggingOut" />
        </div>
    </div>
    <div id="page_title">
        ADMINISTRATION
    </div>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder2" runat="Server">
    <div id="left_content">
        <div class="menu">
            <ul>
                <li><a href="Home.aspx">Home</a></li>
                <li><a href="#" class="current">Create New Client</a></li>
                <li><a href="Mng_Site.aspx">Manage Sites</a></li>
                <li><a href="Mng_Machine.aspx">Manage Machines</a></li>
                <li><a href="Mng_Comp.aspx">Manage Components</a></li>
                <li><a href="Mng_Report.aspx">Manage Reports</a></li>
                <li><a href="Mng_WO.aspx">Manage Work Order</a></li>
                <li><a href="Mng_FaultsRecom.aspx">Manage Faults Recommendation</a></li>
            </ul>
        </div>
    </div>
    <!-- end of left content -->
    <div id="right_content">
        <div class="content_area">
            <h2>
                Create Client
            </h2>
            <div class="form_box1">
                <asp:FormView ID="FormViewCreateClient" runat="server" DataKeyNames="client_id" DataSourceID="ClientsObjectDataSource"
                    DefaultMode="Insert" OnItemInserted="FormViewCreateClient_ItemInserted" CssClass="dropDownList" OnItemInserting="Client_Inserting">
                    <InsertItemTemplate>
                        <table>
                            <tr>
                                <td>
                                </td>
                                <td colspan="2">
                                    <asp:RegularExpressionValidator ID="client_idRegularExpressionValidator" runat="server"
                                        ErrorMessage="Maximum Client ID lenght is 4 (number only)." ControlToValidate="client_idTextBox"
                                        ValidationExpression="^\d{4}$" ValidationGroup="FormViewCreateClient" CssClass="requiredFieldValidator"></asp:RegularExpressionValidator>
                                </td>
                            </tr>
                            <tr>
                                <td>
                                    <asp:Label ID="ClientIDLabel" runat="server" Text="Client ID:" AssociatedControlID="client_idTextBox"
                                        CssClass="label1"></asp:Label>
                                </td>
                                <td colspan="2">
                                    <asp:TextBox ID="client_idTextBox" runat="server" Text='<%# Bind("client_id") %>'
                                        ReadOnly="False" CssClass="fields1" />
                                </td>
                            </tr>
                            <tr>
                                <td>
                                </td>
                                <td colspan="2">
                                    <asp:RequiredFieldValidator ID="ClientNameRequired" runat="server" ControlToValidate="clientNameTextBox"
                                        ErrorMessage="Client Name is required." ValidationGroup="FormViewCreateClient"
                                        CssClass="requiredFieldValidator"></asp:RequiredFieldValidator>
                                </td>
                            </tr>
                            <tr>
                                <td>
                                    <asp:Label ID="ClientNameLabel" runat="server" Text="Client Name:" AssociatedControlID="clientNameTextBox"
                                        CssClass="label1"></asp:Label>
                                </td>
                                <td colspan="2">
                                    <asp:TextBox ID="clientNameTextBox" runat="server" Text='<%# Bind("clientName") %>'
                                        ToolTip="Client Name is required." AutoCompleteType="Company" CssClass="fields1" />
                                </td>
                            </tr>
                            <tr>
                                <td>
                                </td>
                                <td colspan="2">
                                    <asp:RequiredFieldValidator ID="contactPersonRequired" runat="server" ErrorMessage="Contact Person is required."
                                        ControlToValidate="contactPersonTextBox" ValidationGroup="FormViewCreateClient"
                                        CssClass="requiredFieldValidator"></asp:RequiredFieldValidator>
                                </td>
                            </tr>
                            <tr>
                                <td>
                                    <asp:Label ID="contactPersonLabel" runat="server" Text="Contact Person:" AssociatedControlID="contactPersonTextBox"
                                        CssClass="label1"></asp:Label>
                                </td>
                                <td colspan="2">
                                    <asp:TextBox ID="contactPersonTextBox" runat="server" Text='<%# Bind("contactPerson") %>'
                                        AutoCompleteType="DisplayName" ToolTip="Contact Person is required." CssClass="fields1" />
                                </td>
                            </tr>
                            <tr>
                                <td class="label1">
                                    Status:
                                </td>
                                <td colspan="2">
                                    <asp:DropDownList ID="statusDropDownList" runat="server" Text='<%# Bind("status") %>'
                                        CssClass="dropDownList">
                                        <asp:ListItem Value="Deactivated">Deactivated</asp:ListItem>
                                        <asp:ListItem Value="Activated">Activated</asp:ListItem>
                                    </asp:DropDownList>
                                </td>
                            </tr>
                            <tr>
                                <td class="label1">
                                    Address:
                                </td>
                                <td colspan="2">
                                    <asp:TextBox ID="addressTextBox" runat="server" Text='<%# Bind("address") %>' TextMode="MultiLine"
                                        CssClass="fields1" />
                                </td>
                            </tr>
                            <tr>
                                <td class="label1">
                                    Mobile Phone:
                                </td>
                                <td colspan="2">
                                    <asp:TextBox ID="phoneMobileTextBox" runat="server" Text='<%# Bind("phoneMobile") %>'
                                        AutoCompleteType="Cellular" CssClass="fields1" />
                                </td>
                            </tr>
                            <tr>
                                <td class="label1">
                                    Work Phone:
                                </td>
                                <td colspan="2">
                                    <asp:TextBox ID="phoneWorkTextBox" runat="server" Text='<%# Bind("phoneWork") %>'
                                        AutoCompleteType="BusinessPhone" CssClass="fields1" />
                                </td>
                            </tr>
                            <tr>
                                <td class="label1">
                                    Fax:
                                </td>
                                <td colspan="2">
                                    <asp:TextBox ID="faxTextBox" runat="server" Text='<%# Bind("fax") %>' AutoCompleteType="BusinessFax"
                                        CssClass="fields1" />
                                </td>
                            </tr>
                            <tr>
                                <td>
                                </td> 
                                <td colspan="2">
                                    <asp:RequiredFieldValidator ID="EmailRequired" runat="server" ControlToValidate="emailTextBox"
                                        ErrorMessage="E-mail is required." ValidationGroup="FormViewCreateClient" CssClass="requiredFieldValidator"></asp:RequiredFieldValidator>
                                    <asp:RegularExpressionValidator ID="EmailRegularExpressionValidator" runat="server"
                                        ErrorMessage="Email address not valid." ValidationGroup="FormViewCreateClient"
                                        ControlToValidate="emailTextBox" ValidationExpression="\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*"
                                        CssClass="requiredFieldValidator"></asp:RegularExpressionValidator>
                                </td>
                            </tr>
                            <tr>
                                <td>
                                    <asp:Label ID="emailLabel" runat="server" Text="E-mail:" AssociatedControlID="emailTextBox"
                                        CssClass="label1"></asp:Label>
                                </td>
                                <td colspan="2">
                                    <asp:TextBox ID="emailTextBox" runat="server" Text='<%# Bind("email") %>' ToolTip="E-mail is required."
                                        AutoCompleteType="Email" CssClass="fields1" />
                                </td>
                            </tr>
                            <tr>
                                <td>
                                </td>
                                <td colspan="2">
                                    <asp:RegularExpressionValidator ID="distributionEmailRegularExpressionValidator"
                                        runat="server" ErrorMessage="Email address not valid." ValidationGroup="FormViewCreateClient"
                                        ControlToValidate="distributionEmailTextBox" ValidationExpression="\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*"
                                        CssClass="requiredFieldValidator"></asp:RegularExpressionValidator>
                                </td>
                            </tr>
                            <tr>
                                <td class="label1">
                                    Distribution Email:
                                </td>
                                <td colspan="2">
                                    <asp:TextBox ID="distributionEmailTextBox" runat="server" Text='<%# Bind("distributionEmail") %>'
                                        AutoCompleteType="Email" CssClass="fields1" />
                                </td>
                            </tr>
                            <tr>
                                <td class="label1">
                                    Parent Client:
                                </td>
                                <td colspan="2">
                                    <asp:DropDownList ID="ParentDropDownList" runat="server" AppendDataBoundItems="True"
                                        Text='<%# Bind("parent_client_id") %>' DataSourceID="ClientsObjectDataSource"
                                        DataTextField="clientName" DataValueField="client_id" SelectedValue='<%# Bind("parent_client_id") %>'
                                        CssClass="dropDownList">
                                        <asp:ListItem Text="None" Value=""></asp:ListItem>
                                    </asp:DropDownList>
                                </td>
                            </tr>
                            <tr>
                                <td class="label1">
                                    Paid Status:
                                </td>
                                <td colspan="2">
                                    <asp:DropDownList ID="paid_statusDropDownList" runat="server" Text='<%# Bind("paid_status") %>'
                                        CssClass="dropDownList">
                                        <asp:ListItem Value="Not Paid">Not Paid</asp:ListItem>
                                        <asp:ListItem Value="Paid">Paid</asp:ListItem>
                                    </asp:DropDownList>
                                </td>
                            </tr>
                            <tr>
                                <td class="label1">
                                    Date Registered:
                                </td>
                                <td colspan="2">
                                    <asp:TextBox ID="date_registeredTextBox" runat="server" Text='<%# Bind("date_registered") %>'
                                        class="datepicker" />
                                </td>
                            </tr>
                            <tr>
                                <td class="label1">
                                   Work Scheduled:
                                </td>
                                <td colspan="2">
                                    <asp:TextBox ID="licenced_startTextBox" runat="server" Text='<%# Bind("licenced_start") %>'
                                        class="fields2" />
                                </td>
                            </tr>
                            <tr>
                                <td class="label1">
                                    Licence Expiry Date:
                                </td>
                                <td colspan="2">
                                    <asp:TextBox ID="licenced_expiredTextBox" runat="server" Text='<%# Bind("licenced_expired", "{0:dd/MM/yyyy}") %>'
                                        class="datepicker" />
                                </td>
                            </tr>
                            <tr>
                                <td>
                                </td>
                                <td class="Li_buttonC">
                                    <asp:LinkButton ID="InsertButton" runat="server" CausesValidation="True" ValidationGroup="FormViewCreateClient"
                                        CommandName="Insert" Text="Insert" />
                                </td>
                                <td class="Li_buttonC">
                                    <asp:LinkButton ID="InsertCancelButton" runat="server" CausesValidation="False" CommandName="Cancel"
                                        Text="Cancel" PostBackUrl="Mng_Client.aspx" OnClick="InsertCancelButton_Click" />
                                </td>
                            </tr>
                        </table>
                    </InsertItemTemplate>
                    <ItemTemplate>
                        <table>
                            <tr>
                                <td>
                                    Client ID:
                                </td>
                                <td>
                                    <asp:Label ID="client_idLabel" runat="server" Text='<%# Eval("client_id") %>' />
                                </td>
                            </tr>
                            <tr>
                                <td>
                                    Client Name:
                                </td>
                                <td>
                                    <asp:Label ID="clientNameLabel" runat="server" Text='<%# Bind("clientName") %>' />
                                </td>
                            </tr>
                            <tr>
                                <td>
                                    Contact Person:
                                </td>
                                <td>
                                    <asp:Label ID="contactPersonLabel" runat="server" Text='<%# Bind("contactPerson") %>' />
                                </td>
                            </tr>
                            <tr>
                                <td>
                                    Status:
                                </td>
                                <td>
                                    <asp:Label ID="statusLabel" runat="server" Text='<%# Bind("status") %>' />
                                </td>
                            </tr>
                            <tr>
                                <td>
                                    Address:
                                </td>
                                <td>
                                    <asp:Label ID="addressLabel" runat="server" Text='<%# Bind("address") %>' />
                                </td>
                            </tr>
                            <tr>
                                <td>
                                    Mobile Phone:
                                </td>
                                <td>
                                    <asp:Label ID="phoneMobileLabel" runat="server" Text='<%# Bind("phoneMobile") %>' />
                                </td>
                            </tr>
                            <tr>
                                <td>
                                    Work Phone:
                                </td>
                                <td>
                                    <asp:Label ID="phoneWorkLabel" runat="server" Text='<%# Bind("phoneWork") %>' />
                                </td>
                            </tr>
                            <tr>
                                <td>
                                    Fax:
                                </td>
                                <td>
                                    <asp:Label ID="faxLabel" runat="server" Text='<%# Bind("fax") %>' />
                                </td>
                            </tr>
                            <tr>
                                <td>
                                    Email:
                                </td>
                                <td>
                                    <asp:Label ID="emailLabel" runat="server" Text='<%# Bind("email") %>' />
                                </td>
                            </tr>
                            <tr>
                                <td>
                                    Distribution Email:
                                </td>
                                <td>
                                    <asp:Label ID="distributionEmailLabel" runat="server" Text='<%# Bind("distributionEmail") %>' />
                                </td>
                            </tr>
                            <tr>
                                <td>
                                    Parent Client ID:
                                </td>
                                <td>
                                    <asp:Label ID="parent_client_idLabel" runat="server" Text='<%# Bind("parent_client_id") %>' />
                                </td>
                            </tr>
                            <tr>
                                <td>
                                    Paid Status:
                                </td>
                                <td>
                                    <asp:Label ID="paid_statusLabel" runat="server" Text='<%# Bind("paid_status") %>' />
                                </td>
                            </tr>
                            <tr>
                                <td>
                                    Date Registered:
                                </td>
                                <td>
                                    <asp:Label ID="date_registeredLabel" runat="server" Text='<%# Bind("date_registered") %>' />
                                </td>
                            </tr>
                            <tr>
                                <td>
                                    Work Scheduled:
                                </td>
                                <td>
                                    <asp:Label ID="licenced_startLabel" runat="server" Text='<%# Bind("licenced_start") %>' />
                                </td>
                            </tr>
                            <tr>
                                <td>
                                    Licenced Expired:
                                </td>
                                <td>
                                    <asp:Label ID="licenced_expiredLabel" runat="server" Text='<%# Bind("licenced_expired") %>' />
                                </td>
                            </tr>
                        </table>
                    </ItemTemplate>
                </asp:FormView>
                <asp:ObjectDataSource ID= "ClientsObjectDataSource" runat="server" InsertMethod="Insert"
                    OldValuesParameterFormatString="original_{0}" SelectMethod="GetData" 
                    TypeName="DataAccess.i2iPortalTableAdapters.ClientsTableAdapter" 
                    oninserting="ClientObjectDataSource_Inserting">
                     <InsertParameters>
                        <asp:Parameter Name="client_id" Type="Int32" />
                        <asp:Parameter Name="clientName" Type="String" />
                        <asp:Parameter Name="address" Type="String" />
                        <asp:Parameter Name="contactPerson" Type="String" />
                        <asp:Parameter Name="phoneMobile" Type="String" />
                        <asp:Parameter Name="phoneWork" Type="String" />
                        <asp:Parameter Name="fax" Type="String" />
                        <asp:Parameter Name="email" Type="String" />
                        <asp:Parameter Name="distributionEmail" Type="String" />
                        <asp:Parameter Name="status" Type="String" />
                        <asp:Parameter Name="parent_client_id" Type="Int32" />
                        <asp:Parameter Name="paid_status" Type="String" />
                        <asp:Parameter Name="date_registered" Type="DateTime" />
                        <asp:Parameter Name="licenced_start" Type="String" />
                         <asp:Parameter Name="licenced_expired" Type="DateTime" />
                        <asp:Parameter Name="service_type" Type = "String" />
                    </InsertParameters>
                </asp:ObjectDataSource>
            </div>
        </div>
    </div>
    <!-- end of right content -->
</asp:Content>
